package com.java.star.novel.controller;

import cn.hutool.core.map.MapUtil;
import com.java.star.novel.core.bean.Result;
import com.java.star.novel.entity.Novel;
import com.java.star.novel.no.vo.NovelVO;
import com.java.star.novel.service.NovelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("novel")
@Api(description = "小说推荐接口")
public class RecommendController {

    @Autowired
    private NovelService novelService;

    @ApiOperation("获取本周强推小说")
    @GetMapping("getWeekRecommendNovel")
    public Result getWeekRecommendNovel() {
        List<Novel> novelList = novelService.getWeekRecommendNovel();
        return Result.ok().data(MapUtil.builder()
                .put("novelList", novelList).build());
    }

    @ApiOperation("获取热门推荐小说")
    @GetMapping("getHotRecommendNovel")
    public Result getHotRecommendNovel() {
        List<NovelVO> novelList = novelService.getHotRecommendNovel();
        return Result.ok().data(MapUtil.builder()
                .put("novelList", novelList).build());
    }

    @ApiOperation("获取精品推荐小说")
    @GetMapping("getQualityRecommendNovel")
    public Result getQualityRecommendNovel() {
        List<NovelVO> novelList = novelService.getQualityRecommendNovel();
        return Result.ok().data(MapUtil.builder()
                .put("novelList", novelList).build());
    }

}

